package com.weitu.environmental.solidWaste.service.impl;

import com.weitu.environmental.solidWaste.entity.SolidWasteStorageDispose;
import com.weitu.environmental.solidWaste.mapper.*;
import com.weitu.environmental.solidWaste.service.SolidWasteStorageDisposeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

/**
 * @author zhangqingxi 2017-04-17
 */
@Service
public class SolidWasteStorageDisposeServiceImpl implements SolidWasteStorageDisposeService {
    private final SolidWasteStorageDisposeMapper solidWasteStorageDisposeMapper;
    private final UnitDisposeMapper unitDisposeMapper;
    private final EntrustDisposeMapper entrustDisposeMapper;
    private final ExitDisposeMapper exitDisposeMapper;


    @Autowired
    public SolidWasteStorageDisposeServiceImpl(SolidWasteStorageDisposeMapper solidWasteStorageDisposeMapper, UnitDisposeMapper unitDisposeMapper, EntrustDisposeMapper entrustDisposeMapper, ExitDisposeMapper exitDisposeMapper) {
        this.solidWasteStorageDisposeMapper = solidWasteStorageDisposeMapper;
        this.unitDisposeMapper = unitDisposeMapper;
        this.entrustDisposeMapper = entrustDisposeMapper;
        this.exitDisposeMapper = exitDisposeMapper;
    }





    @Override
    public List<SolidWasteStorageDispose> findByParam(Map paramMap) {
        return solidWasteStorageDisposeMapper.findByParam(paramMap);
    }

    @Override
    public Integer findByParamCount(Map paramMap) {
        return solidWasteStorageDisposeMapper.findByParamCount(paramMap);
    }

    @Override
    public SolidWasteStorageDispose findById(String id) {
        return solidWasteStorageDisposeMapper.findById(id);
    }

    @Transactional
    @Override
    public Integer add(Map paramMap) {
        return solidWasteStorageDisposeMapper.add(paramMap);
    }

    @Transactional
    @Override
    public Integer add(List<Map> unitDisposeList, List<Map> entrustDisposeList, List<Map> exitDisposeList, Map paramMap) {
        if (unitDisposeList.size() > 0) {
            //执行添加 部门内部数据
            unitDisposeMapper.add(unitDisposeList);
        }

        if (entrustDisposeList.size() > 0) {
            //执行添加 外委单位
            entrustDisposeMapper.add(entrustDisposeList);
        }

        if (exitDisposeList.size() > 0) {
            //执行添加 出口国
            exitDisposeMapper.add(exitDisposeList);
        }

        return solidWasteStorageDisposeMapper.add(paramMap);
    }

    @Transactional
    @Override
    public Integer updateById(Map paramMap) {
        return solidWasteStorageDisposeMapper.updateById(paramMap);
    }

    @Transactional
    @Override
    public Integer updateById(List<Map> unitDisposeList, List<Map> entrustDisposeList, List<Map> exitDisposeList, Map paramMap, String id) {
        return 0;
    }


}
